from devicetest.api import Asserts

from devicetest.aw.OpenHarmony import CommonOH
from devicetest.core.test_case import TestCase, Step

from aw.common import common_setup, common_teardown
from aw.pom import SMSMMS


class PreTest_RK3568_Communication_SMSMMS_0100(TestCase, SMSMMS):
    # 预置条件：
    # 烧写目标版本后，正常进入桌面
    # 测试步骤：
    # 进入或反复进入信息应用
    # 预期结果：
    # 信息可正常打开，无卡死、黑屏、白屏等现象

    def __init__(self, controllers):
        self.TAG = self.__class__.__name__
        TestCase.__init__(self, self.TAG, controllers)

    def setup(self):
        common_setup(self.Phone1)

    def process(self):
        for i in range(1, 6):
            Step('步骤{}.0：进入信息应用'.format(i))
            CommonOH.startAbility(self.Phone1, self.ability_name, self.bundle_name)
            CommonOH.wait(self.Phone1, 2)
            Step('预期结果{}.1：信息应用打开无卡死、黑屏、白屏等现象'.format(i))
            # 控件检查
            CommonOH.checkIfTextExist(self.Phone1, '信息')
            Step('步骤{}.2：点击返回键'.format(i))
            CommonOH.pressBackKey(self.Phone1)
            CommonOH.wait(self.Phone1, 2)

    def teardown(self):
        common_teardown(self.Phone1, self.bundle_name)
